package edu.nanyang.struts;

import java.util.List;

import org.apache.struts2.json.annotations.JSON;

import com.opensymphony.xwork2.ActionSupport;

import edu.nanyang.domain.Province;
import edu.nanyang.hibernate.service.IProvinceService;

@SuppressWarnings("serial")
public class ProvinceAction extends ActionSupport {
	private IProvinceService provinceService;
	private List<Province> list;
	private String provinceName;
	private String result;
	public String addProvince(){
		Province p=new Province();
		p.setName(provinceName);
		result = this.provinceService.addProvince(p);
		return SUCCESS;
	}
	public String acquireAllProvince() {
		list = this.provinceService.acquireAllProvince();
		for (Province p : list) {
			System.out.println("province=" + p.getName());
		}
		return SUCCESS;
	}

	@JSON(serialize = false)
	public IProvinceService getProvinceService() {
		return provinceService;
	}

	public void setProvinceService(IProvinceService provinceService) {
		this.provinceService = provinceService;
	}

	public List<Province> getList() {
		return list;
	}

	public void setList(List<Province> list) {
		this.list = list;
	}

	public String getProvinceName() {
		return provinceName;
	}

	public void setProvinceName(String provinceName) {
		this.provinceName = provinceName;
	}
	public String getResult() {
		return result;
	}
	public void setResult(String result) {
		this.result = result;
	}

}
